//
//  BaseMBView.m
//  LiangPinZS
//
//  Created by hwd on 17/3/22.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "BaseMBView.h"

@interface BaseMBView ()

@property (nonatomic, strong) UIView  *contentView;
@end

@implementation BaseMBView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self layoutAllSubviews];
    }
    return self;
}
- (void)layoutAllSubviews{
    
    /*创建灰色背景*/
    _bgView = [[UIView alloc] initWithFrame:self.frame];
    _bgView.backgroundColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.4];
    [self addSubview:_bgView];
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissContactView:)];
    [_bgView addGestureRecognizer:tapGesture];
}
#pragma mark - 手势点击事件,移除View
- (void)dismissContactView:(UITapGestureRecognizer *)tapGesture{
    
    [self dismissContactView];
}
-(void)dismissContactView//移除视图回调
{
    if (_dissBlock) {
        self.dissBlock();
    }
}
// 这里加载在了window上
-(void)showView:(UIViewController *)selfVC
{
    if (selfVC == nil) {
         [selfVC.view addSubview:appDelegate.window];
    }else
    {
         [selfVC.view addSubview:self];
    }
   
}
@end
